home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1998 August: Tool Chest / Dev.CD Aug 98 TC.toast / Sample Code / Games / MoofWars / Tim's Libraries / Scaling.h < prev    next >
Encoding:
C/C++ Source or Header  |  1996-08-19  |  2.7 KB  |  78 lines  |  [TEXT/CWIE]

  1. /*************************************************************************************
  2. #
  3. #    Scaling.h
  4. #    
  5. #    Scaling implements a standard 2D canvas to draw a set of TGraphics and tiles into.
  6. #    It also provides a set of globals that allow the sprite's location to be relative
  7. #   to a specific camera location.
  8. #
  9. #
  10. #    Author: Timothy Carroll
  11. #    Apple Developer Technical Support
  12. #    timc@apple.com
  13. #
  14. #    Modification History: 
  15. #
  16. #    8/15/96        TMC     Initial Release
  17. #
  18. #    Copyright © 1996 Apple Computer, Inc., All Rights Reserved
  19. #
  20. #
  21. #    You may incorporate this sample code into your applications without
  22. #    restriction, though the sample code has been provided "AS IS" and the
  23. #    responsibility for its operation is 100% yours.  However, what you are
  24. #    not permitted to do is to redistribute the source as "DSC Sample Code"
  25. #    after having made changes. If you're going to re-distribute the source,
  26. #    we require that you make it clear in the source that the code was
  27. #    descended from Apple Sample Code, but that you've made changes.
  28. #
  29. *************************************************************************************/
  30.  
  31. #ifndef _SCALING_
  32. #define _SCALING_
  33.  
  34. #include "QuickDraw.h"
  35.  
  36. // We define all the world coordinate scaling information here, and also define functions
  37. // for choosing the drawing buffer and clipping to it.  The drawing buffer will be used by
  38. // TGraphic and TTile objects and any other class of offscreen blitters we make in the future.
  39.  
  40.  
  41. // WorldRect32 is a rectangle in 16.16 fixed point coordinates.  FixedPoint coordinates are
  42. // used for all coordinates in the game.  Anything in world coordinates should be converted
  43. // to screen coordinates before being drawn.
  44. // This structure defines a rectangle in 16.16 fixed point coordinates -- these are used as
  45. // the world coordinates for the game, they must be translated into screen coordinates
  46. // before drawing can take place.
  47.  
  48. struct WorldRect32 {
  49.     SInt32 top;
  50.     SInt32 left;
  51.     SInt32 bottom;
  52.     SInt32 right;
  53. };
  54.  
  55. // For the most part, we define a number of globals that can be read freely, but 
  56. // the functions should be called whenever one of these globals needs to be updated.
  57. // This is because more than one global might need to be set, and the functions do the
  58. // right thing.
  59.  
  60.  
  61.  
  62. extern SInt32             gWorldCoordX;
  63. extern SInt32             gWorldCoordY;
  64. extern Rect               gClipRect;
  65. extern SInt32             gClipCenterX;
  66. extern SInt32             gClipCenterY;
  67.  
  68. extern PixMapHandle     gDestPixMap;
  69. extern PixMapHandle     gBackPixMap;
  70. extern unsigned char    *gDestBaseAddr;
  71. extern unsigned char    *gBackBaseAddr;
  72. extern UInt32            gRowBytes;
  73.     
  74. extern void SetDestinationBuffer(PixMapHandle inDestPixMap, PixMapHandle inBackPixMap);
  75. extern void SetBufferClip(Rect *inClipRect);
  76. extern void SetWorldOrigin (SInt32 x, SInt32 y);
  77.  
  78. #endif // _SCALING_